<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户登陆</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/nprogress.css">
    <link rel="stylesheet" type="text/css" href="/static/css/style.css">
    <link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css">
    <link rel="apple-touch-icon-precomposed" href="/static/images/icon.png">
    <link rel="shortcut icon" href="/static/images/favicon.ico">
    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/js/nprogress.js"></script>
    <script src="/static/js/jquery.lazyload.min.js"></script>
    <!--[if gte IE 9]>
    <script src="/static/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/static/js/html5shiv.min.js" type="text/javascript"></script>
    <script src="/static/js/respond.min.js" type="text/javascript"></script>
    <script src="/static/js/selectivizr-min.js" type="text/javascript"></script>
    <![endif]-->
    <!--[if lt IE 9]>
    <script>window.location.href = 'upgrade-browser.html';</script>
    <![endif]-->
</head>
<body class="user-select">
<header class="header">
    <nav class="navbar navbar-default" id="navbar">
        <div class="container">
            <div class="collapse navbar-collapse" id="header-navbar">
                <ul class="nav navbar-nav navbar-right">
                    <li><a data-cont="首页" title="首页" href="/">首页</a></li>
                    <li><a data-cont="热门话题" title="热门话题" href="/topic/list.html">热门话题</a></li>
                    <li><a data-cont="注册" title="注册" href="/user/register.html">注册</a></li>
                    <li><a data-cont="登录" title="登录" href="/user/login.html">登录</a></li>
                    <li><a data-cont="发布" title="发布" href="/weibo/publish.html">发布</a></li>
                </ul>
            </div>
        </div>
    </nav>
</header>
<section class="container">
    <div class="content-wrap">
        <div class="content">
            <h3 class="form-title">用户登陆</h3>
            <div class="form-group">
                <label class="control-label">登录名</label>
                <div>
                    <input class="form-control" type="text" placeholder="请输入对应的登录用户名" name="loginName" id="loginName"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">登录密码</label>
                <div>
                    <input class="form-control" type="password" placeholder="请输入对应的登录用户的密码" name="password"
                           id="password"/>
                </div>
            </div>
            <div class="form-actions">
                <button class="btn" id="login" type="submit">登陆</button>
            </div>
        </div>

    </div>
</section>

</body>

<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/jquery.ias.js"></script>
<script src="/static/js/scripts.js"></script>


<script type="text/javascript">
    $(function () {
        $("#login").on("click", function () {
            var loginName = $("#loginName").val();
            var password = $("#password").val();
            if (loginName == "" || password == "") {
                alert("输入缺少必要参数");
                return false;
            }
            $.ajax({
                type: "POST",
                contentType: "application/x-www-form-urlencoded",
                url: "/user/login",
                data: {
                    "loginName": loginName,
                    "password": password
                },
                success: function (data) {
                    if (data.success) {
                        alert("success");
                    } else {
                        alert(data.data);
                    }

                },
                error: function (data) {
                    alert("登陆失败，原因为" + data.responseText);
                }
            })

        });
    });

</script>
</html>